import { Button, Tooltip, Input, message, Table, Space } from 'antd';
import { QuestionCircleOutlined, SearchOutlined } from '@ant-design/icons';
import { FilterConfirmProps, FilterDropdownProps } from 'antd/es/table/interface';
import './TableSearch.css'
const handleSearch = (selectedKeys: any, confirm: any, dataIndex: any) => {
    confirm();
};

const handleReset = (clearFilters: any) => {
    clearFilters();
};

const getColumnSearchProps = (dataIndex: any) => ({
    filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }: FilterDropdownProps) => (
        <div style={{ padding: 8 }}>
            <Input
                value={selectedKeys[0]}
                onChange={(e) => setSelectedKeys(e.target.value ? [e.target.value] : [])}
                onPressEnter={() => handleSearch(selectedKeys, confirm, dataIndex)}
                style={{ marginBottom: 8, display: 'block' }}
            />
            <Space>
                <Button
                    type="primary"
                    onClick={() => {
                        confirm({ closeDropdown: true });
                    }}
                    icon={<SearchOutlined />}
                    size="small"
                    style={{ width: 90 }}
                    className='GeneralButton'
                >
                    搜索
                </Button>
                <Button onClick={() => handleReset(clearFilters)} size="small" style={{ width: 90 }} className='DangerButton' type='primary'>
                    重置
                </Button>
            </Space>
        </div>
    ),
    onFilter: (value: any, record: any) =>
        record[dataIndex]
            ? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase())
            : '',
});
export {
    getColumnSearchProps,
};
